package com.test.daily.leetcode.y2021.m11.day1105;

import java.util.HashMap;

/**
 * @descriptions:
 * @author: Tom
 * @date: 2021/11/5 下午 09:42
 * @version: 1.0
 */
public class Code01_LongestSubsequence {
    public int longestSubsequence(int[] arr, int difference) {
        HashMap<Integer, Integer> hashMap = new HashMap<>();
        int ans = 0;
        for(int ele: arr){
            hashMap.put(ele, hashMap.getOrDefault(ele - difference,0) + 1);
            ans = Math.max(ans, hashMap.get(ele));
        }
        return ans;
    }
}
